"""
@Author: 霍格沃兹测试开发学社-西西
@Desc: 更多测试开发技术探讨，请访问：https://ceshiren.com/t/topic/15860
"""
"""
实战练习2
定义一个字典
向字典中添加多个元素（字符型，列表型，整形，字典型）
删除一个元素
通过 key 值获取对应的 value 值
"""
# mydict = {"name":"lili" , "age":20, "like": ["sport", 'music','wright code'],
#           "address":{"school_address": "北京西二旗", "home_address": "河北xxx"}}

# get ['key']
# mylike = mydict.get('like')[1]
# print(type(mylike))
# print(mylike)
#
# myaddress = mydict['address']['home_address']
# print(type(myaddress))
# print(myaddress)
#
# print(mydict.pop("address").pop("school_address"))
# print(mydict)
# mydict1 = {}
# for k,v in mydict.items():
#     print(k,v)
#     if k == "address":
#         v.pop("school_address")
#     mydict1[k]=v
#
# print(mydict1)

# mydict.get("address").pop("school_address")
# print(mydict)

"""
练习1
将它的key和value分别进行交换。也就是key变成值，值变成key。

输入: {‘a’: 1, ‘b’: 2, ‘c’: 3}
输出: {1: ‘a’, 2: ‘b’, 3: ‘c’}
"""

mydict = {'a': 1, 'b': 2, 'c': 3}
mydict1 = {}
# # {1:"a"}
# mydict1[1]="a"
# print(mydict1)
#
# mydict1[2]="b"
# print(mydict1)
#
# mydict1[3]="c"
# print(mydict1)
#
# mydict1[3]="d"
# print(mydict1)

for key,value in mydict.items():
    print(key,value)
    mydict1[value] = key

print(mydict1)
